#ifndef __RING_BUFFER_H_
#define __RING_BUFFER_H_

#include <stdint.h>
typedef struct ring_buffer {
  uint32_t size;
  uint32_t tail;
  uint32_t head;
  uint8_t *buf;
} ring_buffer_t;

ring_buffer_t *ring_buffer_new(uint32_t size);
uint32_t ring_buffer_len(ring_buffer_t *buf);
int ring_buffer_add(ring_buffer_t *buf, const void *data, uint32_t datlen);
int ring_buffer_remove(ring_buffer_t *buf, void *data, uint32_t datlen);
int ring_buffer_drain(ring_buffer_t *buf, uint32_t len);
void ring_buffer_free(ring_buffer_t *buf);
int ring_buffer_search(ring_buffer_t *buf, const char *sep, const int seplen);
uint8_t *ring_buffer_write_atmost(ring_buffer_t *buf);

#endif // __RING_BUFFER_H_